#!/bin/bash

identifierList=("a05f7892-fae9-7506-e044-00144fdd4fa6" \
                "a05f7892-daf0-7506-e044-00144fdd4fa6" \
                "a05f7893-0031-7506-e044-00144fdd4fa6" \
                "a66ac3ca-5830-594b-e044-00144fdd4fa6" \
                "c8856c41-0d5b-2b1d-e044-00144fdd4fa6" \
                "da2024d9-c576-5653-e044-00144fdd4fa6" \
                "dfde6a14-42c4-42e8-e044-00144fdd4fa6" \
                "e09363a7-a957-7153-e044-00144fdd4fa6" \
                "e354c6fb-14cc-2442-e044-00144fdd4fa6" \
                "e55d6e3b-37c3-2628-e044-00144fdd4fa6" \
                "e82f3eee-cbff-4b23-e044-00144fdd4fa6" )
    
    echo "<registryObjects xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"
                 xmlns=\"http://ands.org.au/standards/rif-cs/registryObjects http://www.openarchives.org/OAI/2.0/\"
                 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
                 xsi:schemaLocation=\"http://ands.org.au/standards/rif-cs/registryObjects http://services.ands.org.au/documentation/rifcs/schema/registryObjects.xsd\">" > ForGA/GeoscienceAustraliaRegistryObjects.xml

    for i in ${!identifierList[*]}
    do
        uri="http://www.ga.gov.au/geonetwork/srv/en/oaipmh?verb=GetRecord&identifier=${identifierList[$i]}&metadataPrefix=iso19139" 
        printf "$uri\n" 

        echo wget --header='Accept-Language: en-us' $uri -O ${identifierList[$i]}_wget.xml
        wget --header='Accept-Language: en-us' $uri -O ${identifierList[$i]}_wget.xml
        
        echo "Moving on..."

        echo "java -jar /home/anucsiro/workspace/XML/XSLT/saxon9he.jar ${identifierList[$i]}_wget.xml /home/anucsiro/workspace/XML/XSLT/ISO19139_To_RIFCS/GA/GA_rif_refactored.xsl > ForGA/${identifierList[$i]}_rif-cs.xml"

        java -jar /home/anucsiro/workspace/XML/XSLT/saxon9he.jar ${identifierList[$i]}_wget.xml /home/anucsiro/workspace/XML/XSLT/ISO19139_To_RIFCS/GA/GA_rif_refactored.xsl > ForGA/${identifierList[$i]}_rif-cs.xml

        cat ForGA/${identifierList[$i]}_rif-cs.xml >> ForGA/GeoscienceAustraliaRegistryObjects.xml

    done

 echo "</registryObjects>" >> ForGA/GeoscienceAustraliaRegistryObjects.xml

   


